home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / HELPWIND.C < prev    next >
Text File  |  1992-05-14  |  3KB  |  114 lines

  1. /************************************************************************************/
  2. /*    HelpWindowProc                                                                    */
  3. /************************************************************************************/
  4.  
  5. #include "MyHeaders.h"
  6.  
  7. int HelpWindowProc()
  8. {
  9.     int        HelpWindRetCode = 0;
  10.     int        workPart;
  11.     int        h,v;
  12.     Rect    sizeRect;
  13.     ControlHandle    workControlHandle;
  14.     
  15.     SetPort (windTbl[1].windPtr);            /* set as the grafPort                */
  16.  
  17.     workPoint = myEvent.where;
  18.     GlobalToLocal(&workPoint);
  19.  
  20.     switch (myEvent.what)                        /* how did I get here?                */
  21.         {
  22.         case (mouseDown):                        /* MouseDown?                        */
  23.             switch (myMouseWhere)                /*   What part of window?            */
  24.                 {
  25.                 case (inContent):                /*     content region:                */
  26.                     workRect = (**helpList).rView;            /* view area of list    */
  27.                     workRect.right += 16;                    /* plus scroll bar        */
  28.                     if (PtInRect(workPoint, &workRect))        /* if in the list area    */
  29.                         {
  30.                         workBoolean = LClick (workPoint, myEvent.modifiers, helpList);
  31.  
  32.                         for (j=0; j<helpCount; j++)    /* find which cell is on    */
  33.                             {
  34.                             helpCell.h = 0;
  35.                             helpCell.v = j;
  36.                             if (LGetSelect(FALSE, &helpCell, helpList))
  37.                                 break;
  38.                             }
  39.  
  40.                         if ((helpCell.v != helpPrev)
  41.                             && (j < helpCount))
  42.                             {
  43.                             helpPrev = helpCell.v;
  44.                             helpHandle = GetResource('TEXT', 7700 + helpCell.v);
  45.                             helpLong = SizeResource(helpHandle);
  46.                             EraseRect (&(**windTbl[1].windTEH[0]).viewRect);
  47.                             TESetText (*helpHandle+32, helpLong-32,
  48.                                     windTbl[1].windTEH[0]);
  49.                             ReleaseResource (helpHandle);
  50.                             TECalText (windTbl[1].windTEH[0]);
  51.                             myActionProc (windTbl[1].windCntlH[0], 0);
  52.                             InvalRect (&(**windTbl[1].windTEH[0]).viewRect);
  53.                             }
  54.                         }
  55.                     else
  56.                         {
  57.                         workPart = FindControl (workPoint,        /* check for control*/
  58.                                 windTbl[1].windPtr,
  59.                                 &workControlHandle);
  60.                         if (workPart)                    /* if so, track it            */
  61.                             {
  62.                              if (workPart != inThumb)    /* if not in thumb: my proc    */
  63.                                                      /* to scroll and reset thumb    */
  64.                                                      /* on the basis of the scroll    */
  65.                                 TrackControl (workControlHandle, workPoint,
  66.                                         (ProcPtr) -1);
  67.                                 
  68.                             else                    /* in thumb: use native routine    */
  69.                                 {                    /* then invoke my proc to        */
  70.                                                     /* scroll on the basis of thumb    */
  71.                                 k = GetCtlValue (workControlHandle);
  72.                                 TrackControl (workControlHandle, workPoint, NIL);
  73.                                 k -= GetCtlValue (workControlHandle);
  74.                                 myActionProc(workControlHandle, (short) workPart);
  75.                                 }
  76.                             }
  77.                         }
  78.                 break;
  79.                 
  80.                 case (inDrag):                    /*     drag region:                    */
  81.                     DragWindow (windTbl[1].windPtr,
  82.                                 myEvent.where, &myDragRect);
  83.                 break;
  84.                 
  85.                 case (inGoAway):                /*     goaway region:                */
  86.                     if (TrackGoAway (windTbl[1].windPtr, myEvent.where))
  87.                         WorkRetCode = HelpCloseProc();
  88.                 break;
  89.                 }
  90.              
  91.         break;
  92.         
  93.         case (activateEvt):
  94.             j = (int) BitAnd(myEvent.modifiers, activeFlag);
  95.  
  96.             if (j)                                /* if activate...                    */
  97.                 {
  98.                 WorkRetCode = MenuUpdate(ProcHelp);                    /* set menus    */
  99.                 ShowControl (windTbl[1].windCntlH[0]);
  100.                 HiliteControl (windTbl[1].windCntlH[0], 0);
  101.                 LActivate (TRUE, helpList);
  102.                 }
  103.             else                                /* if deactivate...                    */
  104.                 {
  105.                 HiliteControl (windTbl[1].windCntlH[0], 255);        /* unhilite        */
  106.                 HideControl (windTbl[1].windCntlH[0]);        /* hide (to match L/M)    */
  107.                 LActivate (FALSE, helpList);
  108.                 }
  109.         break;
  110.         }
  111.  
  112.     return HelpWindRetCode;
  113. }
  114.